function slowLoad(el, str, length) {
	if (length > str.length) {
		length = 0
	}
	el.innerText = str.substr(0, length)
	setTimeout(() => {
		slowLoad(el, str, length + 1)
	}, 1000)
}
export default {
	install(vue) {
		vue.directive('slow-load', {
			mounted(el) {
				let width = el.offsetWidth
				el.style.display = "inline-block"
				el.style.width = width + 'px'
				let str = el.innerText
				if (str.length < 2) {
					console.warn(
						"the element that use v-slow-load directive must have innerText and innerText's length >=2",
						el)
				} else {
					slowLoad(el, str, 0)
				}
			}
		})
	}
}
